
const state = {
  fields: [], // fields
  ListFields: [],
};


const actions = {
  GetFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'id',
        align: 'center',
        width: 200
      },
      {
        title: '分组名称',
        dataIndex: 'group_name',
        align: 'center',
      },
      {
        title: '排序',
        dataIndex: 'order',
        align: 'center',
        defaultSortOrder: 'descend',
        sorter: (a, b) => a.order - b.order,
      },
      {
        title: '创建时间',
        dataIndex: 'create_time',
        align: 'center',
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 150,
      }
    ];
    commit('setfields', fields);
  },
  getListFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'id',
        align: 'center',
        width: 200
      },
      {
        title: '所属分组',
        dataIndex: 'group_name',
        align: 'center',
      },
      {
        title: '快捷回复',
        dataIndex: 'content',
        align: 'center',
        defaultSortOrder: 'descend',
        // sorter: (a, b) => a.order - b.order,
      },
      {
        title: '创建时间',
        dataIndex: 'create_time',
        align: 'center',
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 150,
      }
    ];
    commit('setlistfields', fields);
  },
};

const mutations = {
  setlistfields(state, lists) {
    state.ListFields = lists;
  },
  setfields(state, lists) {
    // console.log(state)
    state.fields = lists;
  },
  // SetTotal(state, lists) {
  //   // console.log(state)
  //   state.page.total = lists;
  // },
};

export default {
  namespaced: true,
  state,
  actions,
  mutations
};
